﻿using Microsoft.Xna.Framework.Input;
using Syngine;
using Syngine.Components.ParticleSystems;
using Syngine.Components.Screens;
using Syngine.Input.Keyboard;

namespace BenchMark.ParticleSystems
{
	public class ParticleSystemScreen : Screen
	{
		private ParticleSystem _particleSystem;

		public ParticleSystemScreen(ScreenController screenController) : base(screenController)
		{
		}

		public override void Initialize()
		{
			_particleSystem = new ParticleSystem(100.0f, 20.0f);

			_particleSystem.Initialize();

			Input.If(i => i.WasReleased(Keys.P)).Call(c => _particleSystem.Pause());
			Input.If(i => i.WasReleased(Keys.S)).Call(c => _particleSystem.Stop());

			base.Initialize();
		}

		public override void LoadContent(LoadContext context)
		{
			_particleSystem.LoadContent(context);
		}

		protected override void UpdateCore(UpdateContext context)
		{
			_particleSystem.Update(context);
		}

		public override void UnloadContent()
		{
		}

		protected override void DrawCore(DrawContext context)
		{
			_particleSystem.Draw(context);
		}
	}
}